

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>Ceph 文件系统洗刷 &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/doctools.js"></script>
        <script src="../../_static/sphinx_highlight.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="处理占满的 Ceph 文件系统" href="../full/" />
    <link rel="prev" title="Ceph 文件系统客户端的驱逐" href="../eviction/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../">Ceph 文件系统</a></li>
      <li class="breadcrumb-item active">Ceph 文件系统洗刷</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../../_sources/cephfs/scrub.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../" class="icon icon-home"> Ceph
          

          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../">Ceph 文件系统</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../#cephfs">CephFS 入门</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id4">管理</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id5">挂载 CephFS</a></li>
<li class="toctree-l2"><a class="reference internal" href="../#id6">CephFS 内幕</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../#id7">故障排除和灾难恢复</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../eviction/"> 驱逐客户端</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#"> 洗刷</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id1">初始化文件系统洗刷</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id2">监视（进行中的）文件系统洗刷操作</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id3">控制（进行中的）文件系统洗刷</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id4">损坏的</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id5">用递归洗刷甄别流浪者</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../full/"> 文件系统占满的处理</a></li>
<li class="toctree-l3"><a class="reference internal" href="../disaster-recovery-experts/"> 元数据修复</a></li>
<li class="toctree-l3"><a class="reference internal" href="../troubleshooting/"> 故障排除</a></li>
<li class="toctree-l3"><a class="reference internal" href="../disaster-recovery/"> 灾难恢复</a></li>
<li class="toctree-l3"><a class="reference internal" href="../cephfs-journal-tool/"> cephfs-journal-tool</a></li>
<li class="toctree-l3"><a class="reference internal" href="../recover-fs-after-mon-store-loss/"> 监视器存储丢失后恢复文件系统</a></li>
<li class="toctree-l3"><a class="reference internal" href="../#id8">开发者指南</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../#id9">更多细节</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../rbd/">Ceph 块设备</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../monitoring/">监控概览</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../hardware-monitoring/">硬件监控</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <section id="ceph">
<span id="mds-scrub"></span><h1>Ceph 文件系统洗刷<a class="headerlink" href="#ceph" title="Permalink to this heading"></a></h1>
<p>CephFS 为集群管理员（操作员）提供了一系列洗刷命令，可以用以检查文件系统的一致性。洗刷可分类为两部分：</p>
<ol class="arabic simple">
<li><p>正向洗刷（ Forward Scrub ）：此时，洗刷操作从文件系统的根目录（或一个子目录）开始，检查层次结构中可以触及的所有内容，以确保一致性。</p></li>
<li><p>逆向洗刷（ Backward Scrub ）：此时，洗刷操作会检查文件系统存储池中的每个 RADOS 对象，并将其映射回文件系统层次结构。</p></li>
</ol>
<p>本文档详细介绍了启动和控制前向洗刷（后文简称为洗刷）的命令。</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>CephFS 正向洗刷是在 rank 0 上启动和操作的。所有洗刷命令都必须指向 rank 0 。</p>
</div>
<section id="id1">
<h2>初始化文件系统洗刷<a class="headerlink" href="#id1" title="Permalink to this heading"></a></h2>
<p>启动对一个目录树的洗刷操作，用下列命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">tell</span> <span class="n">mds</span><span class="o">.&lt;</span><span class="n">fsname</span><span class="o">&gt;</span><span class="p">:</span><span class="mi">0</span> <span class="n">scrub</span> <span class="n">start</span> <span class="o">&lt;</span><span class="n">path</span><span class="o">&gt;</span> <span class="p">[</span><span class="n">scrubopts</span><span class="p">]</span> <span class="p">[</span><span class="n">tag</span><span class="p">]</span>
</pre></div>
</div>
<p>其中， <code class="docutils literal notranslate"><span class="pre">scrubopts</span></code> 逗号分隔的列表，内容是 <code class="docutils literal notranslate"><span class="pre">recursive</span></code> 、 <code class="docutils literal notranslate"><span class="pre">force</span></code> 、或
<code class="docutils literal notranslate"><span class="pre">repair</span></code> ，还有 <code class="docutils literal notranslate"><span class="pre">tag</span></code> ，它是一个可选的定制字符串标签（默认值是生成的 UUID ）。命令实例：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">tell</span> <span class="n">mds</span><span class="o">.</span><span class="n">cephfs</span><span class="p">:</span><span class="mi">0</span> <span class="n">scrub</span> <span class="n">start</span> <span class="o">/</span> <span class="n">recursive</span>
<span class="p">{</span>
    <span class="s2">&quot;return_code&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
    <span class="s2">&quot;scrub_tag&quot;</span><span class="p">:</span> <span class="s2">&quot;6f0d204c-6cfd-4300-9e02-73f382fd23c1&quot;</span><span class="p">,</span>
    <span class="s2">&quot;mode&quot;</span><span class="p">:</span> <span class="s2">&quot;asynchronous&quot;</span>
<span class="p">}</span>
</pre></div>
</div>
<p>递归洗刷是异步的（上面输出中的 <cite>mode</cite> 说了）。
异步洗刷必须用 <code class="docutils literal notranslate"><span class="pre">scrub</span> <span class="pre">status</span></code> 进行轮询，才能看到状态。</p>
<p>洗刷标签（ scrub tag ）用于区分洗刷，也用于在默认数据存储池
（回溯信息存储的位置）中标记每个 inode 的第一个数据对象，
并在 <code class="docutils literal notranslate"><span class="pre">scrub_tag</span></code> 扩展属性中写入该标签的值。
用 RADOS 工具查看扩展属性，
就可以验证一个 inode 是否已被洗刷。</p>
<p>洗刷操作可以同时在多个活跃 MDS（多个 rank ）上进行。
洗刷由 rank 0 管理，并根据情况分配到各个 MDS 。</p>
</section>
<section id="id2">
<h2>监视（进行中的）文件系统洗刷操作<a class="headerlink" href="#id2" title="Permalink to this heading"></a></h2>
<p>可以用 <code class="docutils literal notranslate"><span class="pre">scrub</span> <span class="pre">status</span></code> 命令监视和轮询正在进行的洗刷操作。
该命令会列出正在进行的洗刷（从标签认出的），
以及启动洗刷的路径和选项：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">tell</span> <span class="n">mds</span><span class="o">.</span><span class="n">cephfs</span><span class="p">:</span><span class="mi">0</span> <span class="n">scrub</span> <span class="n">status</span>
<span class="p">{</span>
    <span class="s2">&quot;status&quot;</span><span class="p">:</span> <span class="s2">&quot;scrub active (85 inodes in the stack)&quot;</span><span class="p">,</span>
    <span class="s2">&quot;scrubs&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s2">&quot;6f0d204c-6cfd-4300-9e02-73f382fd23c1&quot;</span><span class="p">:</span> <span class="p">{</span>
            <span class="s2">&quot;path&quot;</span><span class="p">:</span> <span class="s2">&quot;/&quot;</span><span class="p">,</span>
            <span class="s2">&quot;options&quot;</span><span class="p">:</span> <span class="s2">&quot;recursive&quot;</span>
        <span class="p">}</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p><cite>status</cite> 显示的是按计划随时可进行洗刷的 inode 数量，
因此，随后用 <cite>scrub status</cite> 查看时会变化。此外，
洗刷操作的高级汇总（其中包括操作状态和开始洗刷的路径）
也会显示在 <cite>ceph status</cite> 中：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">status</span>
<span class="p">[</span><span class="o">...</span><span class="p">]</span>

<span class="n">task</span> <span class="n">status</span><span class="p">:</span>
  <span class="n">scrub</span> <span class="n">status</span><span class="p">:</span>
      <span class="n">mds</span><span class="mf">.0</span><span class="p">:</span> <span class="n">active</span> <span class="p">[</span><span class="n">paths</span><span class="p">:</span><span class="o">/</span><span class="p">]</span>

<span class="p">[</span><span class="o">...</span><span class="p">]</span>
</pre></div>
</div>
<p>当不再显示在此列表中时，洗刷就完成了（不过在未来的版本中可能会有所变化）。
有损坏的话会在集群健康警告里报告。</p>
</section>
<section id="id3">
<h2>控制（进行中的）文件系统洗刷<a class="headerlink" href="#id3" title="Permalink to this heading"></a></h2>
<ul>
<li><p>暂停（ Pause ）：暂停进行中的洗刷操作会导致正在进行的 RADOS 操作
（对应当前正被洗刷的 inode ）结束后，不再洗刷新的或待处理的 inode ：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">tell</span> <span class="n">mds</span><span class="o">.</span><span class="n">cephfs</span><span class="p">:</span><span class="mi">0</span> <span class="n">scrub</span> <span class="n">pause</span>
<span class="p">{</span>
    <span class="s2">&quot;return_code&quot;</span><span class="p">:</span> <span class="mi">0</span>
<span class="p">}</span>
</pre></div>
</div>
<p>暂停后的 <code class="docutils literal notranslate"><span class="pre">scrub</span> <span class="pre">status</span></code> 会反映暂停后的状态。此时，
启动新的洗刷操作（通过 <code class="docutils literal notranslate"><span class="pre">scrub</span> <span class="pre">start</span></code> ）
将只是把这些 inode 放入洗刷队列：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">tell</span> <span class="n">mds</span><span class="o">.</span><span class="n">cephfs</span><span class="p">:</span><span class="mi">0</span> <span class="n">scrub</span> <span class="n">status</span>
<span class="p">{</span>
    <span class="s2">&quot;status&quot;</span><span class="p">:</span> <span class="s2">&quot;PAUSED (66 inodes in the stack)&quot;</span><span class="p">,</span>
    <span class="s2">&quot;scrubs&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s2">&quot;6f0d204c-6cfd-4300-9e02-73f382fd23c1&quot;</span><span class="p">:</span> <span class="p">{</span>
            <span class="s2">&quot;path&quot;</span><span class="p">:</span> <span class="s2">&quot;/&quot;</span><span class="p">,</span>
            <span class="s2">&quot;options&quot;</span><span class="p">:</span> <span class="s2">&quot;recursive&quot;</span>
        <span class="p">}</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
</li>
<li><p>恢复（ Resume ）：恢复启动已暂停的洗刷操作：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">tell</span> <span class="n">mds</span><span class="o">.</span><span class="n">cephfs</span><span class="p">:</span><span class="mi">0</span> <span class="n">scrub</span> <span class="n">resume</span>
<span class="p">{</span>
    <span class="s2">&quot;return_code&quot;</span><span class="p">:</span> <span class="mi">0</span>
<span class="p">}</span>
</pre></div>
</div>
</li>
<li><p>中止（ Abort ）：在进行中的 RADOS 操作（对应当前正在洗刷的 inode ）结束后，
中止正在进行的洗刷操作会从洗刷队列中删除待处理的 inode
（从而中止洗刷）：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">tell</span> <span class="n">mds</span><span class="o">.</span><span class="n">cephfs</span><span class="p">:</span><span class="mi">0</span> <span class="n">scrub</span> <span class="n">abort</span>
<span class="p">{</span>
    <span class="s2">&quot;return_code&quot;</span><span class="p">:</span> <span class="mi">0</span>
<span class="p">}</span>
</pre></div>
</div>
</li>
</ul>
</section>
<section id="id4">
<h2>损坏的<a class="headerlink" href="#id4" title="Permalink to this heading"></a></h2>
<p>文件系统洗刷操作能够报告和修复的损坏类型有：</p>
<ul class="simple">
<li><p>DENTRY : Inode 的 dentry 丢失了。</p></li>
<li><p>DIR_FRAG : Inode 的目录片段丢失了。</p></li>
<li><p>BACKTRACE : Inode 放在数据存储池里的的回溯信息损坏了。</p></li>
</ul>
<p>上面说的这些 MDS 损坏可以用下列命令修复：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">tell</span> <span class="n">mds</span><span class="o">.&lt;</span><span class="n">fsname</span><span class="o">&gt;</span><span class="p">:</span><span class="mi">0</span> <span class="n">scrub</span> <span class="n">start</span> <span class="o">/</span><span class="n">path</span> <span class="n">recursive</span><span class="p">,</span> <span class="n">repair</span><span class="p">,</span> <span class="n">force</span>
</pre></div>
</div>
<p>如果洗刷能够修复损坏的，那么对应的条目会从损坏表自动删除。</p>
</section>
<section id="id5">
<h2>用递归洗刷甄别流浪者<a class="headerlink" href="#id5" title="Permalink to this heading"></a></h2>
<ul>
<li><p>为了甄别流浪者，即清除 <code class="docutils literal notranslate"><span class="pre">~mdsdir</span></code> 中的流浪目录，用以下命令：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">tell</span> <span class="n">mds</span><span class="o">.&lt;</span><span class="n">fsname</span><span class="o">&gt;</span><span class="p">:</span><span class="mi">0</span> <span class="n">scrub</span> <span class="n">start</span> <span class="o">~</span><span class="n">mdsdir</span> <span class="n">recursive</span>
</pre></div>
</div>
</li>
<li><p>从 CephFS 根目录启动洗刷时， <code class="docutils literal notranslate"><span class="pre">~mdsdir</span></code> 默认不会进入队列。要在根目录下执行流浪者甄别，加上 <code class="docutils literal notranslate"><span class="pre">scrub_mdsdir</span></code> 和 <code class="docutils literal notranslate"><span class="pre">recursive</span></code> 标志运行洗刷：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">ceph</span> <span class="n">tell</span> <span class="n">mds</span><span class="o">.&lt;</span><span class="n">fsname</span><span class="o">&gt;</span><span class="p">:</span><span class="mi">0</span> <span class="n">scrub</span> <span class="n">start</span> <span class="o">/</span> <span class="n">recursive</span><span class="p">,</span><span class="n">scrub_mdsdir</span>
</pre></div>
</div>
</li>
</ul>
</section>
</section>



<div id="support-the-ceph-foundation" class="admonition note">
  <p class="first admonition-title">Brought to you by the Ceph Foundation</p>
  <p class="last">The Ceph Documentation is a community resource funded and hosted by the non-profit <a href="https://ceph.io/en/foundation/">Ceph Foundation</a>. If you would like to support this and our other efforts, please consider <a href="https://ceph.io/en/foundation/join/">joining now</a>.</p>
</div>


           </div>
           
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="../eviction/" class="btn btn-neutral float-left" title="Ceph 文件系统客户端的驱逐" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="../full/" class="btn btn-neutral float-right" title="处理占满的 Ceph 文件系统" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).</p>
  </div>

   

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>